package org.leetcode.easy.leetcode136;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

public class Solution {
    public int singleNumber(int[] nums) {

        HashSet<Integer> set = new HashSet<>();

        for (int i = 0; i < nums.length; i++) {
            if (set.contains(nums[i]))
            {
                set.remove(nums[i]);
            }else {
                set.add(nums[i]);
            }
        }

        return new ArrayList<>(set).get(0);
    }

    public static void main(String[] args) {
        HashSet<Integer> set = new HashSet<>();

        set.add(3);

        System.out.println(set.add(3));
    }
}
